<?php

class Router_Route extends Router_Route_Abstract
{

    public function match($request)
    {
        $path = $request -> getPathInfo();
        $path = trim($path, '/') . '/';

        if ($this -> _check && $result = preg_match($this -> _check, $path, $match))
        {
            $vals = $this -> _defs;
            foreach ($match as $key => $value)
            {
                if (is_string($key))
                {
                    $vals[$key] = trim($match[$key], '/');
                }
            }

            $actionId = $this -> mapActionId($vals);

            if ($request -> isDispatchable($actionId))
            {
                $request -> setActionId($actionId);
                return 1;
            }
        }
        return 0;
    }

}
